package com.grt192.benchtest.controller;

import com.grt192.benchtest.mechanism.BenchFinaleMechanism;
import com.grt192.core.EventController;
import com.grt192.event.SensorEvent;
import com.grt192.event.component.ButtonListener;
import com.grt192.mechanism.GRTDriverStation;
import com.grt192.sensor.GRTJoystick;

/**
 *
 * @author anand
 */
public class BenchFinaleController extends EventController implements ButtonListener{

    private BenchFinaleMechanism finale;
    private GRTDriverStation ds;

    public BenchFinaleController(BenchFinaleMechanism finale, GRTDriverStation ds) {
        this.finale = finale;
        this.ds = ds;
        ((GRTJoystick) ds.getSensor("leftJoystick")).addButtonListener(this);
    }

    public void buttonUp(SensorEvent e, String key) {
        if (key.equals("Button5") || key.equals("Button6")) {
            finale.stop();
        }
    }

    public void buttonDown(SensorEvent e, String key) {
        if (key.equals("Button5")) {
            finale.extend();
        } else if (key.equals("Button6")) {
            finale.retract();
        }
    }
}
